CS-10684: Fix test run instances being overwritten across factory iterations#4357
Merged
CS-10684: Fix test run instances being overwritten across factory iterations#4357
Conversation
…rations The realm search index may not have indexed the TestRun from the previous iteration by the time the next one queries getNextSequenceNumber, causing it to return the same sequence number and overwrite the previous TestRun. Add a lastSequenceNumber floor that callers track across iterations, so Math.max(indexResult, lastSequenceNumber) + 1 always increments even when the search index is stale. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Software Factory bug where repeated test executions could overwrite the same TestRun card when the realm search index lags behind newly created runs, by allowing callers to provide a “floor” for sequence number allocation.
Changes:
- Add
lastSequenceNumbertoExecuteTestRunOptionsand use it to computeMath.max(indexLatest, lastSequenceNumber) + 1when creating a new TestRun. - Track and pass
lastSequenceNumberacross factory loop iterations andrun_teststool invocations to avoid reusing sequence numbers during stale indexing. - Add a regression unit test that simulates a stale search index returning no runs across consecutive calls.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/software-factory/tests/factory-test-realm.test.ts | Adds regression test covering stale-index sequence reuse prevention via lastSequenceNumber. |
| packages/software-factory/scripts/lib/test-run-types.ts | Extends execution options with lastSequenceNumber and documents stale-index behavior. |
| packages/software-factory/scripts/lib/test-run-execution.ts | Applies lastSequenceNumber floor when computing the next TestRun sequence number. |
| packages/software-factory/scripts/lib/factory-tool-builder.ts | Tracks lastSequenceNumber across run_tests tool calls and forwards it into execution. |
| packages/software-factory/scripts/lib/factory-implement.ts | Tracks lastSequenceNumber across factory loop iterations and forwards it into execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…per-slug - Add sequenceNumber to TestRunHandle and return it from resolveTestRun and executeTestRunFromRealm, eliminating fragile regex parsing of testRunId - Track lastSequenceNumber per-slug in buildRunTestsTool using a Map, so different slugs get independent sequence floors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lukemelia
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getNextSequenceNumberquerylastSequenceNumberfloor parameter that callers track across iterations, ensuringMath.max(indexResult, lastSequenceNumber) + 1always increments even when the search index is stalebuildTestRunner(factory loop path) andbuildRunTestsTool(agent tool path)Test plan
🤖 Generated with Claude Code